#define  _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
using namespace std;
#include <vector>
#include<string>
int main() {
    int n = 0;
    cin >> n;
    vector<string> v;
    for (int i = 0; i < n; i++) {
        string s1;
        cin >> s1;
        v.push_back(s1);
    }
    for (int j = 0; j < n; j++) {
        if (v[j].size() >= 10) {
            auto it = v[j].begin();
            auto it1 = v[j].rbegin();
            int a = v[j].size();
            cout << *it;
            cout << to_string(a);
            cout << *it1<<endl;
        }
        else {
            cout << v[j] << endl;
        }

    }
    return 0;
}

/*class Solution {

public:
    int FirstNotRepeatingChar(string str) {
        for (int i = 0; i < str.size(); i++) {
            int a = str.find(str[i]);
            int b = str.rfind(str[i]);
            if (a == b) {
                return a;
            }
        }
        return -1;
    }
};

class Solution {
public:
    bool isUnique(string astr) {

        for (int i = 0; i < astr.size(); i++)
        {
            int index = astr.find(astr[i]);
            int reverse_index = astr.rfind(astr[i]);
            if (index != reverse_index)
            {
                return false;
            }
        }
        return true;
    }
};

class Solution {
public:
    bool CheckPermutation(string s1, string s2) {
        if (s1.size() != s2.size())
        {
            return false;
        }
        int table1[256] = { 0 };
        int table2[256] = { 0 };
        int a = s1.size();
        int i = 0;
        while (a) {
            table1[s1[i]] += 1;
            table2[s2[i]] += 1;
            i++;
            a--;
        }
        for (int j = 0; j < 256; j++)
        {
            if (table1[j] != table2[j])
            {
                return false;
            }
        }
        return true;
    }
};

class Solution {
public:
    bool canPermutePalindrome(string s) {
        int table[256] = { 0 };
        int a = s.size();
        int i = 0;
        while (a) {
            table[s[i]] += 1;
            a--;
            i++;
        }
        int b = 0;
        int c = 0;
        for (int j = 0; j < 256; j++)
        {
            if (table[j] != 0 && table[j] % 2 == 0) {
                b++;
            }
        }
        for (int j = 0; j < 256; j++)
        {
            if (table[j] % 2 == 1) {
                c++;
            }
        }
        if (c == 0 && b != 0) {
            return true;
        }
        if (c == 1) {
            return true;
        }
        return false;
    }
};
*/